//package cn.zhangxd.platform.common.web.config;
//
//import cn.zhangxd.platform.common.web.security.AuthenticationTokenFilter;
//import cn.zhangxd.platform.common.web.security.MyAuthenticationEntryPoint;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
//
///**
// * spring-security配置
// *
// * @author zhangxd
// */
//@EnableWebSecurity
//@EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true)
//public class AbstractWebSecurityConfig extends WebSecurityConfigurerAdapter {
//    /**
//     * 用户信息服务
//     */
//    @Autowired
//    private UserDetailsService userDetailsService;
//
//    /**
//     * Password encoder password encoder.
//     *
//     * @return the password encoder
//     */
//    @Bean
//    public PasswordEncoder passwordEncoder() {
//        return new BCryptPasswordEncoder(8);
//    }
//
//    @Override
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        auth
//            .userDetailsService(this.userDetailsService)
//            .passwordEncoder(this.passwordEncoder())
//        ;
//    }
//
//    @Bean
//    @Override
//    public AuthenticationManager authenticationManagerBean() throws Exception {
//        return super.authenticationManagerBean();
//    }
//
//    /**
//     * Authentication token filter bean authentication token filter.
//     *
//     * @return the authentication token filter
//     */
//    @Bean
//    public AuthenticationTokenFilter authenticationTokenFilterBean() {
//        return new AuthenticationTokenFilter();
//    }
//
//    @Override
//    protected void configure(HttpSecurity security) throws Exception {
//        security
//            .csrf().disable()
//            .exceptionHandling().authenticationEntryPoint(new MyAuthenticationEntryPoint()).and()
//            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
//            .authorizeRequests()
//            .anyRequest().authenticated();
//
//        // Custom JWT based security filter
//        security
//            .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
//    }
//}
